package com.neusoft.yuejian_01.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.adapter.ProfessorCourseAdapter;
import com.neusoft.yuejian_01.base.BaseActivity;
import com.neusoft.yuejian_01.javabean.ProfessorCourseBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.model.ProfessorModel;

import java.util.List;

public class ProfessorCourseActivity extends BaseActivity implements RetrofitListener{
    private RecyclerView recyclerView;
    private ProfessorCourseAdapter adapter;
    public TextView professortitleView;
    private int pm_id;
    private ImageButton button_back;//返回按钮

     protected void initView() {
         setContentView(R.layout.activity_professor_course);
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        professortitleView = (TextView) findViewById(R.id.professor_title);
        button_back = (ImageButton) findViewById(R.id.button_back);
    }
     protected void initEvents() {
        button_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
     protected void initData() {
        pm_id = getIntent().getIntExtra("pm_id",-1);
        String pm_name = getIntent().getStringExtra("pm_name");
        professortitleView.setText(pm_name);
        ProfessorModel professorModel = new ProfessorModel();
        professorModel.professorcourselist(String.valueOf(pm_id),this);
    }
    @Override
    public void onSuccess(Object object, int flag) {
        List<ProfessorCourseBean> professorCourseBean = (List<ProfessorCourseBean>) object;
        adapter = new ProfessorCourseAdapter(ProfessorCourseActivity.this, professorCourseBean);
        LinearLayoutManager layoutManager = new LinearLayoutManager(ProfessorCourseActivity.this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }
    @Override
    public void onFail() {
        Toast.makeText(this,"fail",Toast.LENGTH_LONG).show();
    }
}




